﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using GoblinXNA;
using GoblinXNA.SceneGraph;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GoblinXNA.Graphics;
using GoblinXNA.Graphics.Geometry;

namespace ping
{
    public class Paddle : GeometryNode
    {
        TransformNode t;
        static GoblinXNA.Graphics.Model paddleModel = new Box(10, 10, 0.4f);
        int note;

        public TransformNode Trans
        {
            get { return t; }
        }
        public int Note
        {
            get { return this.note; }
            set 
            { 
                this.note = value;
                if (value == 0)
                    this.Physics.MaterialName = "paddle";
                else
                    this.Physics.MaterialName = "paddleWithNote_" + this.note.ToString();
            }
        }
        public Paddle()
        {
            note = 0;
            this.Model = paddleModel;
            //this.Model.Shader = shader;
            this.Physics.MaterialName = "paddle";
            this.Physics.Collidable = true;
            this.Physics.Interactable = false;
            this.Physics.Shape = GoblinXNA.Physics.ShapeType.Box;
            this.AddToPhysicsEngine = true;
            this.Physics.Mass = 0;


            // Make this box model cast and receive shadows
            this.Model.CastShadows = true;
            this.Model.ReceiveShadows = true;

            t = new TransformNode();

            // Create a material to apply to the box model
            Material paddleMaterial = new Material();
            paddleMaterial.Diffuse = Color.Silver.ToVector4();
            paddleMaterial.Specular = Color.White.ToVector4();
            paddleMaterial.SpecularPower = 10;
            this.Material = paddleMaterial;
            t.AddChild(this);
        }
        public Paddle(TransformNode trans)
        {
            //GeometryNode paddle = new GeometryNode("Paddle_" + numPaddles);
            this.Model = paddleModel;
            //this.Model.Shader = shader;
            this.Physics.MaterialName = "paddle";
            this.Physics.Collidable = true;
            this.Physics.Interactable = false;
            this.Physics.Shape = GoblinXNA.Physics.ShapeType.Box;
            this.AddToPhysicsEngine = true;
            this.Physics.Mass = 0;

            // Make this box model cast and receive shadows
            this.Model.CastShadows = true;
            this.Model.ReceiveShadows = true;

            t = trans;

            // Create a material to apply to the box model
            Material paddleMaterial = new Material();
            paddleMaterial.Diffuse = Color.Silver.ToVector4();//Color.Orange.ToVector4();
            paddleMaterial.Specular = Color.White.ToVector4();
            paddleMaterial.SpecularPower = 10;
            this.Material = paddleMaterial;
            t.AddChild(this);
        }

        public void scaleUp()
        {
            t.Scale = t.Scale + new Vector3(0.1f, 0.1f, 0);
        }

        public void scaleDown()
        {
            t.Scale = t.Scale - new Vector3(0.1f, 0.1f, 0);
        }

    }
}
